﻿using UnityEngine;

namespace ZFramework.Runtime
{
    public delegate void AssetLoaderCallback(bool success, string path, Object asset, object userData);
    
    public class AssetLoaderCallbackInfo : IReference
    {
        private AssetLoaderCallback _callback;
        
        private object _userData;
        
        private int _uuid;

        public AssetLoaderCallback Callback => _callback;
        
        public object UserData => _userData;
        
        public int Uuid => _uuid;

        public void Clear()
        {
            _callback = null;
            _userData = null;
            _uuid = 0;
        }

        public static AssetLoaderCallbackInfo Create(AssetLoaderCallback callback, object userData, int uuid)
        {
            var info = ReferencePool.Acquire<AssetLoaderCallbackInfo>();
            info._callback = callback;
            info._uuid = uuid;
            info._userData = userData;
            return info;
        }
    }
}